package io.bluerain.aclient.attach;

import javax.ws.rs.core.Cookie;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by cuilei on 2015/6/11.
 */
public class IndieCookie {

    private List<Cookie> cookies;

    /**
     * 创建一个IndieSeesion对象
     *
     * @return this
     */
    public static IndieCookie builder() {
        IndieCookie ic = new IndieCookie();
        ic.cookies = new ArrayList<Cookie>();
        return ic;
    }

    /**
     * 添加一个键值对的cookie
     *
     * @param name  cookie的name
     * @param value cookie的value
     */
    public IndieCookie put(String name, String value) {
        Cookie cookie = new Cookie(name, value);
        this.cookies.add(cookie);
        return this;
    }

    /**
     * 添加一个cookie对象
     *
     * @param cookie Cookie对象
     */
    public void add(Cookie cookie) {
        this.cookies.add(cookie);
    }

    public List<Cookie> getCookies() {
        return cookies;
    }
}